﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _76超市收银系统
{
    class ChanKu
    {
        //存取货物
        List<List<FuLei>> list = new List<List<FuLei>>();


        public void Shou()
        {
            foreach(var item in list)
            {
                Console.WriteLine("我们仓库有："+item[0].Name+','+"\t"+"有"+item.Count+"个,"+"每个"+item[0].Price+"元");
            }
        }


        public ChanKu()
        {
            list.Add(new List<FuLei>());
            list.Add(new List<FuLei>());
            list.Add(new List<FuLei>());
            list.Add(new List<FuLei>());
        }

        /// <summary>
        /// 进货
        /// </summary>
        /// <param name="strType">货物的类型</param>
        /// <param name="count">货物的数量</param>
        public void JinPros(string strType, int count)
        {
            for(int i = 0; i < count; i++)
            {
                switch (strType)
                {
                    case "Acer": list[0].Add(new Acer(Guid.NewGuid().ToString(), 1000, "鸿基笔记本"));
                        break;
                    case "SanXing": list[1].Add(new SanXing(Guid.NewGuid().ToString(), 2000, "三星手机"));
                        break;
                    case "JianYou": list[2].Add(new JiangYou(Guid.NewGuid().ToString(), 10, "老抽酱油"));
                        break;
                    case "Banana": list[3].Add(new Banana(Guid.NewGuid().ToString(), 20, "香蕉"));
                        break;
                }
            }
        }

        /// <summary>
        /// 从仓库中提取货物
        /// </summary>
        /// <param name="strType"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public FuLei[] GetPros(string strType, int count)
        {
            FuLei[] pros = new FuLei[count];
            for(int i = 0; i < pros.Length; i++)
            {
                switch (strType)
                {
                    case "Acer":
                        if(list[0].Count == 0)
                        {
                            Console.WriteLine("货物已清空");
                        }
                        pros[i] = list[0][0];
                        list[0].RemoveAt(0);
                        break;
                    case "SanXing":pros[i] = list[1][0];
                        list[1].RemoveAt(0);
                        break;
                    case "JiangYou":pros[i] = list[2][0];
                        list[2].RemoveAt(0);
                        break;
                    case "Banana":pros[i] = list[3][0];
                        list[3].RemoveAt(0);
                        break;
                }
            }
            return pros;
        }
    } 
}
